package com.sh.one;

import lombok.SneakyThrows;

import java.lang.reflect.Proxy;

/**
 * 生成RxClient代理对象工厂
 */
public class RxClientFactory {
 
    @SneakyThrows
    public Object getInstance(String className) {
 
        Class<?> aClass = Class.forName(className);
        RxClient annotation = aClass.getAnnotation(RxClient.class);
        return Proxy.newProxyInstance(aClass.getClassLoader(),
                new Class[]{aClass},
                new RxClientProxy(annotation.baseUrl(), annotation.prefix()));
    }
}